home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0064_ASM Calls and Jumps.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  888b  |  48 lines

  1. {
  2. > If I make a Assembly routine in a Turbo Pascal program,
  3. > how can I make far jumps, calls, etc?
  4.  
  5. Here's two procedures:
  6. }
  7.  
  8. procedure CallFar(Where : pointer); assembler;
  9. asm
  10.   call Where
  11. end;
  12.  
  13. procedure JmpFar(Where : pointer); inline($cb);
  14.  
  15. {
  16. > How can I make labels?
  17. You can make local labels.
  18. }
  19.  
  20. asm
  21.   jcxz @1
  22.   shl  ax, cl
  23.  @1:
  24.   add  cx, bx
  25.   ...
  26. end;
  27. {
  28. But with assembly in Pascal you can also make local variables;
  29. }
  30.  
  31. procedure Test; assembler;
  32. var
  33.   MyLocalVar : word; { a variable }
  34. asm
  35.    mov MyLocalVar, 0 { clear contents }
  36. end;
  37.  
  38. {
  39. > how to discover the offset of a certain instruction?
  40.  
  41. To discover the offset for a variable, you might use LEA
  42. (Load Effective Address).
  43. }
  44.    LEA  bx, MyLocalVar { for the above example }
  45. {
  46. Will NOT return the contents of MyLocalVar, but the offset
  47. within the stack segment to MyLocalVar.
  48. }